package com.jxl.dnd.charactercreator.vo.feats
{
	import flash.events.EventDispatcher;

	[Bindable]
	public class Feat extends EventDispatcher
	{
		
		public var name:String;
		public var prerequisite:String;
		public var shortDescription:String;
		public var description:String;
		
		public function Feat()
		{
			super();
		}
		
		public function buildFromObject(obj:Object):void
		{
			this.name					= obj.name;
			this.prerequisite			= obj.prerequisite;
			this.shortDescription		= obj.shortDescription;
			this.description			= obj.description;
		}
		
		public function toObject():Object
		{
			var obj:Object = new Object();
			obj.name					= name;
			obj.prerequisite			= prerequisite;
			obj.shortDescription		= shortDescription;
			obj.description				= description;
			return obj;
		}
		
		// TODO: support CDATA for descriptions
		public function toXML():XML
		{
			var myXML:XML = 
				<feat>
					<name>{name}</name>
					<prerequisite>{prerequisite}</prerequisite>
					<shortdescription>{shortDescription}</shortdescription>
					<description>{description}</description>
				</feat>;
			return myXML;
		}
		
		public function buildFromXML(xml:XML):void
		{
			for each(var featNode:XML in xml..feat)
			{
				name				= featNode.name;
				prerequisite		= featNode.prerequisite;
				shortDescription	= featNode.shortdescription;
				description			= featNode.description;
			}
		}
		
	}
}